﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using mal.balades.Business.DataModel;
using mal.balades.Business.Log;
using mal.balades.Business.Web;

namespace mal.balades.Web.Services
{
    /// <summary>
    /// Summary description for MapServices
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class MapServices : System.Web.Services.WebService
    {

        [WebMethod]
        public List<MapVisitList> GetAllVisitsForMap()
        {
            MalLogManager.WebLogger.Info("");

            List<MapVisitList>  results = BaladesManagerProxy.Instance.GetAllVisitsForMap();
            foreach (MapVisitList item in results)
            {
                item.Url =  UrlManager.VisitUrl(item.Url);
               // item.Picture = GetImage.GetUrl(UrlManager.VisitPictureUrl(item.Picture)); 
                item.Picture = UrlManager.VisitPictureUrl(item.Picture) ;
                item.PlaceCategoryPicture = UrlManager.CategoryPictureUrl(item.PlaceCategoryPicture);
            }

            return results;
        }

        [WebMethod]
        public MapVisitList GetVisitForMap(string visitUrlName)
        {
            MalLogManager.WebLogger.InfoFormat("visitUrlName:{0}", visitUrlName);

            MapVisitList item = BaladesManagerProxy.Instance.GetVisitForMap(visitUrlName);
            
            item.Url = UrlManager.VisitUrl(item.Url);
            // item.Picture = GetImage.GetUrl(UrlManager.VisitPictureUrl(item.Picture)); 
            item.Picture = UrlManager.VisitPictureUrl(item.Picture);
            item.PlaceCategoryPicture = UrlManager.CategoryPictureUrl(item.PlaceCategoryPicture);

            MalLogManager.WebLogger.Info(item);
            return item;
        }
    }
}
